30no2's Blog.

centos7 lamp环境安装

字数统计: 1k阅读时长: 4 min
2019/12/18 Share

contos7 lamp环境安装

1、apache

1)下载依赖包

2)安装(网上找的,靠谱。)

安装之前先将服务器的防火墙关掉。

  systemctl stop firewalld

  systemctl disable firewall

第一步:

  安装apr

    下载:

    wget -c http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.bz2

    解压该文件:

    tar -jvxf apr-1.6.3.tar.bz2
    检测:

    cd apr-1.6.3
    ./configure –prefix=/usr/local/apr/
    编译:

    make
    make install

第二步:

  安装apr-util

    下载:

    wget -c http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2

    解压该文件:
    tar -jvxf apr-util-1.6.1.tar.bz2

    检测:
    cd apr-util-1.6.3
    ./configure –prefix=/usr/local/apr-util/ –with-apr=/usr/local/apr/

    编译:
    make
    make install

第三步:

  安装pcre

    下载:

    wget -c http://ftp.pcre.org/pub/pcre/pcre-8.42.tar.bz2

    解压该文件:
    tar -jvxf pcre-8.42.tar.bz2

    检测:
    cd pcre-8.42
    ./configure –prefix=/usr/local/pcre/

    编译:
    make
    make install

第四步:
  安装httpd

    下载:

    wget -c http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.bz2

    解压该文件:
    tar -jvxf httpd-2.4.29.tar.bz2

    检测:
    cd httpd-2.4.29
    ./configure –prefix=/usr/local/httpd/ –with-apr=/usr/local/apr/ –with-apr-util=/usr/local/apr-util/ –with-pcre=/usr/local/pcre/

    编译:
    make
    make install

第五步:

  配置/usr/local/apache2/conf/httpd.conf

      ServerName www.examda.com:80
      改为
      ServerName localhost:80

第六步:

  启动apache服务

    /usr/local/apache2/bin/apachectl start

3)测试

  使用浏览器访问本地IP

  出现It works!成功

4)报错处理

 (1)configure: error: APR not found. Please read the documentation.

    这是没有安装apr或者apr安装失败导致的,重新安装apr。

    安装请查看第一步。

 (2)configure: error: APR-util not found. Please read the documentation.

    这是没有安装apr-util或者apr-util安装失败导致的,重新安装apr-util。

    安装请查看第二步。

 (3)configure: error: no acceptable C compiler found in $PATH

    这是没有安装gcc编译器或者gcc编译器安装失败导致的,重新安装gcc。

    yum install -y gcc

 (4)xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录

    这是没有安装expat-devel或者expat-devel安装失败导致的,重新安装expat-devel。

    yum install -y expat-devel

 (5)configure: error: Invalid C++ compiler or C++ compiler flags

    这是没有安装gcc-c++或者gcc-c++安装失败导致的,重新安装gcc-c++

    yum install -y gcc-c++

 (6)configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

    这是没有安装pcre或者pcre安装失败导致的,重新安装pcre。

    安装请查看第三步。

​ (7)make[1]: Entering directory `/deployment/apr-util-1.6.0’

​ xml/apr_xml.c:411: error: ‘apr_xml_parser’ has no member named ‘xp’

解决办法:

yum install expat-devel

​ (8) rm: cannot remove ‘libtoolT’: No such file or directory

解决办法

1.使用如下命令打开configure文件

2.找到RM='$RM'修改为RM='$RM -f'

5)设置开机启动

将apache添加为开机启动有两个方法:

1、在/etc/rc.d/rc.local内加入启动命令 /usr/local/apache2/bin/apachectl start

2、将http添加为系统服务

cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd

chmod +x /etc/rc.d/init.d/httpd

[root@localhost ~]# chkconfig –add httpd
[root@localhost ~]# chkconfig –list|grep httpd
httpd 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭

[root@localhost ~]# chkconfig –level 345 httpd on
[root@localhost ~]# chkconfig –list|grep httpd

httpd 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭

如果出现[root@localhost ~]# chkconfig –add httpd
httpd 服务不支持 chkconfig

解决过程如下:

编辑/etc/rc.d/init.d/httpd

#!/bin/bash
#chkconfig:345 61 61 //此行的345参数表示,在哪些运行级别启动,启动序号(S61);关闭序号(K61)

#description:Apache httpd //此行必写,描述服务.

添加红色部分就可以拉!

再[root@localhost ~]# chkconfig –add httpd
[root@localhost ~]# chkconfig –list|grep httpd
httpd 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭

[root@localhost ~]# chkconfig –level 345 httpd on
[root@localhost ~]# chkconfig –list|grep httpd
httpd 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭

6)查看端口状态

netstat -anpt|grep 80

CATALOG
  1. 1. contos7 lamp环境安装
    1. 1.1. 1、apache
      1. 1.1.1. 1)下载依赖包
      2. 1.1.2. 2)安装(网上找的,靠谱。)
      3. 1.1.3. 3)测试
      4. 1.1.4. 4)报错处理
      5. 1.1.5. 5)设置开机启动
      6. 1.1.6. 6)查看端口状态